<?php
/**
 * Created by PhpStorm.
 * User: shkj
 * Date: 2020/4/15
 * Time: 10:49
 */

namespace app\api\controller\v1;


use think\Controller;
use app\lib\exception\ParameterException;
use app\api\service\Token as TokenService;
class Base extends Controller
{
    // function __construct()
    // {
    //     header('Access-Control-Allow-Origin: *');
    //     header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept , identityCheck ,Token , adminToken");
    //     header('Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE,TRACE, OPTIONS, PATCH');

    //     if (Request()->method() == 'OPTIONS') {
    //         exit;
    //     }
    // }

       //校验token是否有效
    public function verifyToken($uid='',$token=''){
        if(!$token || !$uid){
            throw  new ParameterException([
               'token或者uid不允许为空 '
            ]);
        }
        $valid = TokenService::verifyToken($uid,$token);
        // return [
        //     'isValid'=>$valid
        // ];
        if($valid){

           return $valid;
        }else{
            return_json(40001,'token过期了',40001);
        }
    }




}